﻿Imports SASettings
Imports SACommon
Public Class UpdateSettings
    Private mSettings As Settings
    Public Property VersionURL As String
    Async Function GetSettingsControlList() As Task(Of Boolean)
        Dim tempStr As String

        If VersionURL = "" Then Return False

        Try
            mSettings = New Settings(gUpdateFiles.AppDirectory & "startup.ini")

            Dim fd As New FileDownload
            Dim tResult = Await fd.DownloadFileToString(VersionURL)
            If tResult.Result <> SAEventArgs.Results.Success Then Return False
            tempStr = tResult.Message
            If tempStr = "" Then Throw New Exception

            tempStr = Compression.InflateString(tempStr).Trim

            If tempStr <> "" Then
                Dim uf As New StripeFile
                uf.ReadDataString(tempStr)
                For i = 0 To uf.LineItemCount - 1
                    mSettings.Add(uf.GetLineItems(i, 0), uf.GetLineItems(i, 1))
                Next
            End If

            Return True
        Catch
            Return False
        End Try
    End Function
    Sub Add(Key As Integer, Value As String)
        mSettings.Add(Key, Value)
    End Sub
    Sub Save()
        mSettings.SaveFile()
    End Sub
End Class
